package org.linlinjava.litemall.db.domain;

import java.time.LocalDateTime;

public class LitemallSecurityConfig {
    public static final Boolean IS_DELETED = false;
    public static final Boolean NOT_DELETED = true;

    private Integer id;

    private Boolean enableAccessControl;

    private String allowedIpRange;

    private Integer maxConcurrentAccess;

    private Integer rateLimit;

    private Boolean enableWatermark;

    private String watermarkText;

    private LocalDateTime addTime;

    private LocalDateTime updateTime;

    private Boolean deleted;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Boolean getEnableAccessControl() {
        return enableAccessControl;
    }

    public void setEnableAccessControl(Boolean enableAccessControl) {
        this.enableAccessControl = enableAccessControl;
    }

    public String getAllowedIpRange() {
        return allowedIpRange;
    }

    public void setAllowedIpRange(String allowedIpRange) {
        this.allowedIpRange = allowedIpRange;
    }

    public Integer getMaxConcurrentAccess() {
        return maxConcurrentAccess;
    }

    public void setMaxConcurrentAccess(Integer maxConcurrentAccess) {
        this.maxConcurrentAccess = maxConcurrentAccess;
    }

    public Integer getRateLimit() {
        return rateLimit;
    }

    public void setRateLimit(Integer rateLimit) {
        this.rateLimit = rateLimit;
    }

    public Boolean getEnableWatermark() {
        return enableWatermark;
    }

    public void setEnableWatermark(Boolean enableWatermark) {
        this.enableWatermark = enableWatermark;
    }

    public String getWatermarkText() {
        return watermarkText;
    }

    public void setWatermarkText(String watermarkText) {
        this.watermarkText = watermarkText;
    }

    public LocalDateTime getAddTime() {
        return addTime;
    }

    public void setAddTime(LocalDateTime addTime) {
        this.addTime = addTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", enableAccessControl=").append(enableAccessControl);
        sb.append(", allowedIpRange=").append(allowedIpRange);
        sb.append(", maxConcurrentAccess=").append(maxConcurrentAccess);
        sb.append(", rateLimit=").append(rateLimit);
        sb.append(", enableWatermark=").append(enableWatermark);
        sb.append(", watermarkText=").append(watermarkText);
        sb.append(", addTime=").append(addTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", deleted=").append(deleted);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        LitemallSecurityConfig other = (LitemallSecurityConfig) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getEnableAccessControl() == null ? other.getEnableAccessControl() == null : this.getEnableAccessControl().equals(other.getEnableAccessControl()))
            && (this.getAllowedIpRange() == null ? other.getAllowedIpRange() == null : this.getAllowedIpRange().equals(other.getAllowedIpRange()))
            && (this.getMaxConcurrentAccess() == null ? other.getMaxConcurrentAccess() == null : this.getMaxConcurrentAccess().equals(other.getMaxConcurrentAccess()))
            && (this.getRateLimit() == null ? other.getRateLimit() == null : this.getRateLimit().equals(other.getRateLimit()))
            && (this.getEnableWatermark() == null ? other.getEnableWatermark() == null : this.getEnableWatermark().equals(other.getEnableWatermark()))
            && (this.getWatermarkText() == null ? other.getWatermarkText() == null : this.getWatermarkText().equals(other.getWatermarkText()))
            && (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getEnableAccessControl() == null) ? 0 : getEnableAccessControl().hashCode());
        result = prime * result + ((getAllowedIpRange() == null) ? 0 : getAllowedIpRange().hashCode());
        result = prime * result + ((getMaxConcurrentAccess() == null) ? 0 : getMaxConcurrentAccess().hashCode());
        result = prime * result + ((getRateLimit() == null) ? 0 : getRateLimit().hashCode());
        result = prime * result + ((getEnableWatermark() == null) ? 0 : getEnableWatermark().hashCode());
        result = prime * result + ((getWatermarkText() == null) ? 0 : getWatermarkText().hashCode());
        result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    public enum Column {
        id("id"),
        enableAccessControl("enable_access_control"),
        allowedIpRange("allowed_ip_range"),
        maxConcurrentAccess("max_concurrent_access"),
        rateLimit("rate_limit"),
        enableWatermark("enable_watermark"),
        watermarkText("watermark_text"),
        addTime("add_time"),
        updateTime("update_time"),
        deleted("deleted");

        private static final String BEGINNING_DELIMITER = "`";

        private static final String ENDING_DELIMITER = "`";

        private final String column;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getEscapedColumnName() {
            if (this.isKeyword) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }

        public String getAliasedEscapedColumnName() {
            return this.getEscapedColumnName();
        }

        private final boolean isKeyword;

        public boolean isKeyword() {
            return isKeyword;
        }

        Column(String column) {
            this(column, false);
        }

        Column(String column, boolean isKeyword) {
            this.column = column;
            this.isKeyword = isKeyword;
        }
    }
}